name: Java CI

on:
  watch:
    types: started
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest
    if: github.event.repository.owner.id == github.event.sender.id

    steps:
      - uses: actions/checkout@v1
      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Build with Maven
        run: mvn -B package --file pom.xml
      - run: mkdir release && cp target/*-full.jar release
      - run: echo "NOW=$(date +'%Y%m%dT%H%M%S')" >> $GITHUB_ENV
      
      - uses: "marvinpinto/action-automatic-releases@latest"
        with:
          repo_token: "${{ secrets.GITHUB_TOKEN }}"
          automatic_release_tag: dev-${{ env.NOW }}
          prerelease: true
          title: Auto Build - ${{ env.NOW }}
          files: release/*.jar
      - name: Upload artifact
        uses: actions/upload-artifact@v1.0.0
        with:
          # Artifact name
          name: BurpCrypto_${{ env.NOW }}
          # Directory containing files to upload
          path: release
